package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.p2p.util.BitStatesUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * 个人详细情况
 */
@Setter
@Getter
public class UserInfo extends BaseDomain {

    private Integer version = 0; //版本

    private Long bitState = 0L; //位状态

    private String realName; //实名

    private String idNumber; //身份证

    private String phoneNumber;//手机号

    private String email; //邮箱

    private SystemDictionaryItem incomeGrade; //收入

    private SystemDictionaryItem marriage; //婚姻情况

    private SystemDictionaryItem kidCount; //子女情况

    private SystemDictionaryItem educationBackground;//学历

    private SystemDictionaryItem houseCondition; //住房条件

    private Long realAuthId; //实名认证id
    private Long VideAuthId; //视频认证Id

    /*
     * 实名认证对象Id
     * 如果这个id为null,没有实名申请,反之有
     * 如果实名申请被拒绝,把这个实名认证对象id设置为null;反之不需要设置,
     * 还可以通过这个id获取实名认证的那条记录
     */

    public void addBitState(Long state){
        long tempStete = BitStatesUtil.addState(bitState, state);
        bitState = tempStete;
    }

    /**
     * 移除位状态
     * @param
     */
    public void remove(Long state) {
        long tempStete = BitStatesUtil.removeState(bitState, state);
        bitState = tempStete;
    }

    /*
     * 判断是否完成基本资料的认证
     */
    public boolean hasBasicInfo(){
        return BitStatesUtil.hasState(bitState, BitStatesUtil.OP_BASIC_INFO);
    }
    /*
     * 判断是否完成实名认证
     */
    public boolean hasRealAuth(){
        return BitStatesUtil.hasState(BitStatesUtil.OP_REAL_AUTH, bitState);
    }
    /*
     * 判断是否完成视频认证
     */
    public boolean hasVedioAuth(){
        return BitStatesUtil.hasState(bitState, BitStatesUtil.OP_VEDIO_AUTH);
    }
    /*
     * 是否满足借贷条件,上述三种认证的统一管理
     */
    public boolean canBorrow(){
        return hasBasicInfo() && hasRealAuth() && hasVedioAuth();
    }

    /*判断是否有借款申请在审核流程中
     */
    public boolean hasBorrowInProcess(){
        return BitStatesUtil.hasState(bitState,BitStatesUtil.HAS_BIDREQUEST_IN_PROCESS);
    }


}